package com.ushine.design.design.c_behavioral_pattern.h_state.d_transition;

/**
 * 环境类
 *
 * @author yls
 */
public class Screen {
    private ScreenState currentState, normalState, largerState, largestState;

    public Screen() {
        normalState = new NormalState();
        largerState = new LargerState();
        largestState = new LargestState();
        currentState = normalState;
    }

    public void setState(ScreenState state) {
        currentState = state;
    }

    public void onClick() {
        if (this.currentState == normalState) {
            this.setState(largerState);
            this.currentState.display();
        } else if (this.currentState == largerState) {
            this.setState(largestState);
            this.currentState.display();
        } else if (this.currentState == largestState) {
            this.setState(normalState);
            this.currentState.display();
        }

    }
}
